home *** CD-ROM | disk | FTP | other *** search
Text File | 1991-03-06 | 3.9 KB | 85 lines | [TEXT/GEOL] |
- Item 9397208 17-May-90 07:03PDT
-
- From: KEMINK1 Kemink, Joost
-
- To: POWERUP.ENG Power Up Software,PRT
-
- cc: MACAPP.TECH$ MacApp Technical
-
- Sub: External code info
-
- James,
-
- Here is some more information on how the external code mechanism in Xenon
- works.
-
- In Xenon, "black boxes" are connected together to form a data processing chain.
- Black boxes have zero or more inputs, zero or more outputs and parameters.
-
- For every type of black box, an external code resource exists. Every external
- code resource is implemented in about the same way that HyperCard external code
- resources are implemented.
-
- An external code resource implements a number (4 or so) of different routines,
- that are called from a case statement. The case statement determines which
- routine to call, by looking at a selector code in the parameter block.
-
- To answer your question about classes that encapsulate the code behaviour:
-
- At program startup time, all resources of type CUST (this is their type in
- Xenon) are scanned, and for each resource found, an object is created (call it
- a holder-object) that holds information about the resource such as its ID, name
- etc.
-
- Whenever a new black box is created by the user, an object of another class
- (call it box-object) is created and 'linked' to one of the holder-objects, by
- filling one of its fields with a reference to the holder-object.
-
- Then, when the black box needs to be calculated for example, the
- box-object.Calculate method is called, which in turn calls the
- holder-object.Calculate method. The holder-object.Calculate calls some services
- (also implemented by the holder-object) to load the code in memory, lock it
- etc. and then calls the external code after filling in a parameter block with
- the appropriate values.
- The holder-object.Calculate returns to the box-object.Calculate which then can
- do what it wants with the returned values.
-
- It is important to note that, say for a signal chain with two sine generators,
- there are two box-objects but only one holder-object. Both box-objects refer to
- the same (sine) holder object. Since the generators can have parameters that
- differ (for example their frequency), the parameters are stored in the
- box-object. The parameters can be thought of as being 'specific' for each black
- box. On the other hand, the external code that implements the sine
- functionality is the same for both parameters. That's why these non-specific
- characteristics are stored in the holder-object.
-
-
- The communication between the external code and the application is done by
- filling in appropriate fields in a parameter block. A pointer to this parameter
- block is then passed as to the routine that calls the entrypoint of the
- external code.
- A better approach might be to just push the parameters on the stack and push a
- selector code as the last parameter and then call the entrypoint of the
- external code. This may require some assembly language code, but I think it can
- be done.
- I didn't try to do communication between two different code resources directly,
- basically because I didn't have an urgent need to do that in Xenon, also I
- think it adds another level of dificulty to the implementation of the mechanism
- in general. It would be a nice feature however.
-
-
- Since Xenon's source is not mine anymore, I can't provide you with any source
- code. But very useful information can be found in the following places:
-
- • TechNote 135, Getting through CUSToms. I got a lot of the implementation
- ideas from this TechNote. It provides sample code.
- • TechNote 110, MPW: Writing Stand-Alone Code. Another great TechNote,
- especially the implementation of the window definiton procedure that shows the
- case-statement technique in determining which action to take, given a selector.
- • TechNote 256, Globals in Stand-Alone Code?
- • The Inside Macintosh chapters about the structure of WDEF's, CDEF's etc.
-
-
- Joost
-
-